package ks.client.gui.admin.plugin.listeners;

import ks.client.UserContext;
import ks.client.gui.admin.plugin.PluginAdminGUI;
import ks.client.lobby.Lobby;
import ks.managers.plugin.Plugin;

/** 
 * 
 * Adds a plugin to the table model.
 * 
 * @author Jennifer Hunt
 *
 */
public class AddPluginController {
	
	Lobby lobby;
	UserContext context;
	
	/** GUI being managed. */
	PluginAdminGUI pma;
	
	/**
	 * Constructor for AddPluginController. 
	 * 
	 * @param lobby
	 */
	public AddPluginController(Lobby lobby) {
		this.lobby = lobby;
		this.context = lobby.getUserContext();
		this.pma = lobby.getPluginAdminGUI();
	}

	/**
	 * Adds the plugin to the model.
	 * 
	 * @param p
	 */
	public void add(Plugin p) {	

		// update the underlying model.
		PluginModel pluginModel = pma.getModel();
		pluginModel.add(p);
		
		// make change visible.
		pma.refreshTable();
	}

}
